package com.sqstudio.exercise.chapter4{
	
	import flash.events.Event;
	
	import flashx.textLayout.conversion.PlainTextExporter;
	
	import mx.core.BitmapAsset;
	
	import org.papervision3d.materials.BitmapAssetMaterial;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;

	[SWF(width="800",height="600")]
	
	/**
	 *位图元件材质 
	 * @author Nestor
	 * 
	 */	
	public class BitmapAssetsMaterialExample extends BasicView
	{
		
		[Embed(source="assets/2.png")]
		private var pic:Class;
		
		public function BitmapAssetsMaterialExample(viewportWidth:Number=800, viewportHeight:Number=600, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
		{
			super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
			stage.frameRate = 40;
			init();
			this.startRendering();
			

//			BitmapAssetMaterial 也可以 用Flash中 位图导出类 来作为源
//			var material:BitmapAssetMaterial = new BitmapAssetMaterial("mill"); //mill为swc里的位图导出类名，继承自BitmapData

			
		}
		
		private function init():void{
			var bmpAssetsMaterial:BitmapAsset = new pic() as BitmapAsset;
			
			var material:BitmapMaterial = new BitmapMaterial(bmpAssetsMaterial.bitmapData);
			var plane:Plane = new Plane(material,500,300);
			scene.addChild(plane);
		}
		
		override protected function onRenderTick(event:Event=null):void
		{
			super.onRenderTick(event);
		}
	}
}